<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAdminOperationRecordTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('admin_operation_record', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('admin_id')->comment('操作员id');
            $table->string('username',50)->comment('操作员名称');
            $table->string('type',50)->comment('类型add/update/delete');
            $table->string('message',500)->comment('操作内容');
            $table->text('before_data')->nullable()->comment('操作前的数据');
            $table->string('client_ip',50)->comment('IP');
            $table->timestamps();
            $table->index(['admin_id']);
            $table->index(['type']);
            $table->index(['created_at']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('admin_operation_record');
    }
}
